TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../../config.mk

# Inputs
COST_TABLE := $(BENEFIT_COST_PIPELINE)/inflation_adjust_crime_cost/output/cost_table_inflation_adjusted.feather
CLEARANCE_RATE_TABLE := $(BENEFIT_COST_PIPELINE)/adjust_crime_cost_for_clearance_and_reporting_rates/hand/violence_type_to_clearance_rate_xwalk.csv
REPORTING_RATE_TABLE := $(BENEFIT_COST_PIPELINE)/adjust_crime_cost_for_clearance_and_reporting_rates/hand/violence_type_to_reporting_rate_xwalk.csv

# One of the outputs
OUT_FILE := $(OUT_DIR)/appendix_benefit_cost_up_to_date.tex

$(OUT_FILE): $(RMD_FILE) $(COST_TABLE) $(CLEARANCE_RATE_TABLE) $(REPORTING_RATE_TABLE) $(TASK_FNS)
	@mkdir -p $(OUT_DIR)
	@mkdir -p $(PAPER_OUT_DIR)
	$(R_script) -e "rmarkdown::render(input = '$(RMD_FILE)')"
	@cp $(OUT_DIR)/*up_to_date.tex $(PAPER_OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_FILE)

clean:
	rm -rf $(OUT_DIR)/*up_to_date*
